<template>
<div>
  <group>
    <form-preview :header-label="$t('病患详情')":body-items="list" :footer-buttons="buttons1" class="preview"></form-preview>
  </group>
  <toast v-model="isDelete" type="text" :time="1500" is-show-mask text="删除成功" position="bottom"></toast>
</div>
</template>

<script type="text/ecmascript-6">
  import {Toast,Confirm, FormPreview } from 'vux'
  import { Group } from 'vux'
  export default {
    components:{Toast,FormPreview,Group,Confirm},
    data(){
      return{
        list:'',
        buttons1:'',
        isDelete:false
      }
    },
    props:["patient_data"],
    mounted(){
      let relation
      this.Ajax('get','/javaapi/relation/'+this.patient_data.relationId,{},(res)=>{
        relation=res.text
        this.list=[{
          label: '姓名',
          value:this.patient_data.realName
        }, {
          label: '年龄',
          value: this.patient_data.provinceId
        }, {
          label: '电话',
          value:this.patient_data.tel
        },
          {
            label: '关系',
            value: relation
          },
          {
            label: '住址',
            value: this.patient_data.address2Show
          }
        ]
      })

          this.buttons1= [{
            style: 'default',
            text: '删除',
            onButtonClick:this.delete
          }, {
            style: 'primary',
            text: '编辑',
            onButtonClick: this.editPatient
          }]
    },
    methods:{
      delete(){           //取消未付款订单
        let _this=this
        this.$vux.confirm.show({
          title: '是否删除病患',
          // 组件除show外的属性
          onCancel () {
            _this.$vux.confirm.hide()
          },
          onConfirm () {
            _this.Ajax('delete','/javaapi/patient/'+_this.patient_data.pid,{},(res)=>{
              console.log(res)
              if(res.body.body=='success'){
                _this.isDelete=true
                setTimeout(()=>{
                  _this.$router.go(0)
                },1500)
              }
            })
          }
        })
      },
      editPatient(){
        this.$router.push({
          path:'/edit_patient',
          query:this.patient_data
        })
      }
    }
  }

</script>


<style>
</style>
